/******************************************************************************
*spartacrc.c is a program to generate  16 bit digital signature of a file/filepart
*Input: filename
*Output: 16 bit CRC CCIT checksum
*Author:Aaditya Singhvi 
*Date:24th Nov 2010
*SpartaTorrent.All Rights Reserved (c) 2010 
*******************************************************************************/

#include "crc.h"

int main(int argc, char * argv[])
{
	char filename[30]={0};
	char fname_argument[30];
	char *extension;
	unsigned int extension_len=0,length,filename_len;	
	char *torrentextension=".storrent";
	crc filecrc;
	
	if(argc!=2){
	printf("\nUSAGE: ./sparta FILENAME")	;
	}
	if(argc>0){
	extension=strstr(argv[1],torrentextension);
	strcpy(fname_argument,argv[1]);
	extension_len=strlen(extension);
	length=strlen(argv[1]);
	filename_len=length-extension_len;
	strncpy(filename,fname_argument,9);
	printf("\n The filename parsed is :%s\n",filename);
	filecrc=calculatecrc(filename);
	printf("\n The crc of file is :0x%X\n",filecrc);
	}
	return 0;
}
